package com.beta.cat.config;

import com.alibaba.fastjson.parser.ParserConfig;
import org.apache.commons.beanutils.BeanUtilsBean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * 一些工具的全局配置设置
 */
@Configuration
public class UtilsGlobalConfig {

    @PostConstruct
    public void init() {
        try {
            ParserConfig.getGlobalInstance().setSafeMode(true);//将safeMode开启，彻底关闭autoType功能
        } catch (Throwable ignore) {
        }
        try {
            //将commons-beanutils中BeanUtils中数字转换时，null时不要默认为0
            BeanUtilsBean.getInstance().getConvertUtils().register(false, true, 0);
        } catch (Throwable ignore) {
        }
    }

}
